﻿Imports VN.INS.BL.BC
Imports System.Data
Imports System.IO
Imports Microsoft.Office.Interop

Partial Class Devida_ReporteFormato6
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not (Me.Page.IsPostBack) Then
            Listaperiodo()
            btnGenerar.Attributes.Add("onclick", "javascript:document.getElementById('" + btnGenerar.ClientID + "').disabled=true;" + Me.GetPostBackEventReference(btnGenerar))
        End If
    End Sub

    Protected Sub gvInforme_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvInforme.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim hfPPER As HiddenField = CType(e.Row.FindControl("hfPPER"), HiddenField)
            Dim hfTipo As HiddenField = CType(e.Row.FindControl("hfTipo"), HiddenField)
            Dim hfNom As HiddenField = CType(e.Row.FindControl("hfNom"), HiddenField)
            Select Case hfTipo.Value
                Case "TOTAL"
                    e.Row.Cells(0).Text = "TOTAL"
                Case "C"
                    e.Row.Cells(0).Text = "TOTAL PRODUCTOS"
                Case "B"
                    e.Row.Cells(0).Text = "TOTAL PROYECTOS"
                Case "A"
                    e.Row.Cells(0).Text = "ACCIONES COMUNES"
                Case Else
                    e.Row.Cells(0).ColumnSpan = 8
                    e.Row.Cells(1).Visible = False
                    e.Row.Cells(2).Visible = False
                    e.Row.Cells(3).Visible = False
                    e.Row.Cells(4).Visible = False
                    e.Row.Cells(5).Visible = False
                    e.Row.Cells(6).Visible = False
                    e.Row.Cells(7).Visible = False
                    e.Row.Cells(0).Text = hfNom.Value
            End Select
            e.Row.BackColor = Drawing.Color.FromArgb(255, 255, 255)
            e.Row.Cells(0).BackColor = Drawing.Color.FromArgb(240, 240, 240)
            e.Row.Cells(0).Font.Bold = True
            e.Row.Cells(0).ForeColor = Drawing.Color.Black
        End If
    End Sub

    Protected Sub btnGenerar_Click(sender As Object, e As ImageClickEventArgs) Handles btnGenerar.Click
        divReporte.Style("display") = "none"

        Dim objDt As New DataTable
        Dim objBC As New FormatoBC
        objDt = objBC.DetalleFormato6(ddlPeriodo.SelectedValue)
        gvInforme.DataSource = objDt
        gvInforme.DataBind()

        divReporte.Style("display") = "block"
    End Sub

    Private Sub Listaperiodo()
        Dim objBC As GeneralBC
        Dim objDt As DataTable
        Try
            objBC = New GeneralBC
            objDt = New DataTable
            objDt = objBC.ListaMes(Session("Año"))
            ddlPeriodo.DataSource = objDt
            ddlPeriodo.DataTextField = "DESCRIPCION"
            ddlPeriodo.DataValueField = "PERIODO"
            ddlPeriodo.DataBind()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

End Class
